import request from '@/utils/request'

// 查询会员信息列表
export function listInfo(query) {
  return request({
    url: '/member/info/list',
    method: 'get',
    params: query
  })
}

// 查询会员信息详细
export function getInfo(memberId) {
  return request({
    url: '/member/info/' + memberId,
    method: 'get'
  })
}

// 启用会员信息
export function enable(memberId) {
  return request({
    url: '/member/info/enable/' + memberId,
    method: 'put'
  })
}

// 冻结会员信息
export function freeze(memberId) {
  return request({
    url: '/member/info/freeze/' + memberId,
    method: 'put'
  })
}

// 新增会员信息
export function addInfo(data) {
  return request({
    url: '/member/info',
    method: 'post',
    data: data
  })
}

// 修改会员信息 实名认证
export function updateInfo(data) {
  return request({
    url: '/member/info/certification',
    method: 'put',
    data: data
  })
}

// 删除会员信息
export function delInfo(memberId) {
  return request({
    url: '/member/info/' + memberId,
    method: 'delete'
  })
}

// 导出会员信息
export function exportInfo(query) {
  return request({
    url: '/member/info/export',
    method: 'get',
    params: query
  })
}

//转换会员等级信息
export function selectLevelLabel(datas, value) {
  var actions = [];
  Object.keys(datas).some((key) => {
    if (datas[key].levelId == ('' + value)) {
      actions.push(datas[key].levelName);
      return true;
    }
  })
  return actions.join('');
}
